package laserdancer.smart.com.criminalintent;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * Created by ares on 2018/1/30.
 */

public class CrimeLab {
    private static CrimeLab sCrimeLab;

    private List<Crime> mCrimes;

    public static CrimeLab get(Context _context){
        if(sCrimeLab == null){
            sCrimeLab = new CrimeLab(_context);
        }
        return sCrimeLab;
    }

    public void addCrime(Crime c){
        mCrimes.add(c);
    }

    private CrimeLab(Context _context){
        mCrimes = new ArrayList<>();
        for(int i=0;i<100;i++){
            Crime _crime=new Crime();
            _crime.setTitle("Crime #"+i);
            _crime.setSolved(i%2==0);
            mCrimes.add(_crime);
        }
    }

    public List<Crime> getCrimes() {
        return mCrimes;
    }

    public void setCrimes(List<Crime> _crimes) {
        mCrimes = _crimes;
    }

    public Crime getCrime(UUID _id){
        for(Crime _crime:mCrimes){
            if(_crime.getId().equals(_id)){
                return _crime;
            }
        }

        return null;
    }
}
